package com._23DesignPattern;

/**
 * @Author: huangya
 * @Date: 2019/5/6
 * @Description:
 */
public class Test implements Runnable {

    private volatile int aaa=1;

    private volatile StringBuffer stringBuffer=new StringBuffer("111111");

    @Override
    public void run() {
        ++aaa;
        stringBuffer.append("234");
        System.out.println(aaa);
        System.out.println(stringBuffer.toString());
    }

    public static void main(String[] args) throws InterruptedException {
        Test t1 = new Test();
        Test t2 = new Test();
        new Thread(t1).start();
        new Thread(t2).start();
        Thread.sleep(3000);
        System.out.println("--------------------");
        System.out.println(t1.aaa);
        System.out.println(t1.stringBuffer);
        System.out.println(t2.aaa);
        System.out.println(t2.stringBuffer);
    }
}
